<?php
session_start();
if(isset($_SESSION['admin_id'])) {
    include('../../include/dbFunctions.php');
    $_SESSION['mes']="";
    $school_id= $_SESSION['school_id'];
//Retrieve data from AJAX data sent by jEditable
$updateID = $_SESSION['id'];

$contact_id=$_POST['contact_id'];

    $contact_name = htmlspecialchars($_POST['contact_name'],ENT_QUOTES);
    $contact_email = htmlspecialchars($_POST['contact_email'],ENT_QUOTES);
    $contact_salutation = htmlspecialchars($_POST['contact_salutation'],ENT_QUOTES);
    $contact_designation = htmlspecialchars($_POST['contact_designation'],ENT_QUOTES);
    $office_number = htmlspecialchars($_POST['office_number'],ENT_QUOTES);
    $mobile_number = htmlspecialchars($_POST['mobile_number'],ENT_QUOTES);
    $contact_password = SHA1($_POST['contact_password']);
    $contact_status=htmlspecialchars($_POST['contact_status'],ENT_QUOTES);
if($contact_password==SHA1('__________')){
        $query1 = "UPDATE contact_school
            SET contact_name = '".$contact_name."',
                contact_email = '".$contact_email."',
                contact_designation= '".$contact_designation."',
                contact_salutation = '".$contact_salutation."',
                office_number = '".$office_number."',
                mobile_number = $mobile_number,
                contact_status = '".$contact_status."'
            WHERE contact_school_id=$contact_id";
    } else{
         $query1 = "UPDATE contact_school
            SET contact_name = '".$contact_name."',
                contact_email = '".$contact_email."',
                contact_designation= '".$contact_designation."',
                contact_salutation = '".$contact_salutation."',
                office_number = '".$office_number."',
                mobile_number = $mobile_number,
                contact_password = '".$contact_password."',
                contact_status = '".$contact_status."'
            WHERE contact_school_id=$contact_id";
    }
$result1 = executeQuery($query1);
   if ($result1!=0) {
        $_SESSION['mes'] = "Your record has been updated successfully.";
    } else {
        $_SESSION['mes'] = "Error! Please try again";
    }$link = "../schoolView.php?id=$school_id";
    header("Location: $link ");

}else {
    header("Location: ../../include/login.html");
}
?>
